package updown.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import updown.handler.auth.AuthInterceptor;

/**
 * <p>Title: com.damai.config </p>
 * <p>Description:super:拦截器注入 -  </p>
 *
 * @Author:jiangkaixin
 * @Date:2021/3/10
 * @Version: 1.0
 */
@Configuration
@Slf4j
public class AuthConfig implements WebMvcConfigurer {

    @Bean
    public HandlerInterceptor initInterceptor(){
        return new AuthInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("AuthConfig.addInterceptors(),方法进入>>>:{}", registry);
        registry.addInterceptor(initInterceptor()).addPathPatterns("/**").excludePathPatterns("/login")
        .excludePathPatterns("/home");
    }
}
